<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/tags/struts-bean" prefix="bean"%>
<%@ taglib uri="/tags/struts-html" prefix="html"%>
<%@ taglib uri="/tags/struts-logic" prefix="logic"%>
<html:html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title></title>
	<META http-equiv=Pragma content=no-cache>
	<META http-equiv=Cache-Control content=no-cache>
	<META http-equiv=Expires content=0>
	<link rel="stylesheet"
		href="<%=request.getContextPath()%>/resource/css/style.css"
		type="text/css">
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/util.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/style/scripts/util.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/AdyhUtil.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/js/Validator.js"></script>
	<script language="javascript" type="text/javascript"
		src="<%=request.getContextPath()%>/resource/calendar/DCDA_C03.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/adapter/ext/ext-base.js"></script>
	<script type="text/javascript"
		src="<%=request.getContextPath()%>/style/ext/ext-all.js"></script>	
	<script>
/**保存*/
function ShowAlert()
{ResetMe();	
	var productCode = document.getElementById("productCode").value;
	var manufacturingHours = document.getElementById("manufacturingHours").value;
	var productType = document.getElementById("productType").value;
	var modelCode = document.getElementById("modelCode").value;
	var familyCode = document.getElementById("familyCode").value;	
	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "block";
    objPrompt.innerHTML = "";
	if(productCode.length==0||manufacturingHours.length==0
		||productType.length==0||modelCode.length==0||familyCode.length==0
		||isNumber(productCode)||!check_naturalnumber(manufacturingHours)){		
		if(productCode.length==0){
			objPrompt.innerHTML += "<li><bean:message key="F02.ProductCode"/> <bean:message key="adyh.error.isnull"/>";
			document.getElementById("productCode").className = "MyControlError";
		}
		if(manufacturingHours.length==0){			
			objPrompt.innerHTML += "<li><bean:message key="F02.ManufacturingHours"/> <bean:message key="adyh.error.isnull"/>";
			document.getElementById("manufacturingHours").className = "MyControlError";
		}
		if(productType.length==0){
			objPrompt.innerHTML += "<li><bean:message key="adyh.productType"/> <bean:message key="adyh.error.isnull"/>";
			document.getElementById("productType").className = "MyControlError";
		}
		if(modelCode.length==0){
			objPrompt.innerHTML += "<li><bean:message key="F02.ModelType"/> <bean:message key="adyh.error.isnull"/>";
			document.getElementById("modelCode").className = "MyControlError";
		}
		if(familyCode.length==0){
			objPrompt.innerHTML += "<li><bean:message key="F02.FamilyCode"/> <bean:message key="adyh.error.isnull"/>";
			document.getElementById("familyCodeBy").className = "MyControlError";
		}
		if(isNumber(productCode)){
			objPrompt.innerHTML += "<li><bean:message key="F02.ProductCode"/> <bean:message key="adyh.error.number"/>";
			document.getElementById("productCode").className = "MyControlError";			
		}
		if(!check_naturalnumber(manufacturingHours)){
			objPrompt.innerHTML += "<li><bean:message key="F02.ManufacturingHours"/> <bean:message key="adyh.error.number"/>";
			document.getElementById("manufacturingHours").className = "MyControlError";			
		}		
	}else{		
		var operationType = document.getElementById("operationType").value;
		operation(operationType);
	}
}
/**重置*/
function ResetMe()
{    
	document.getElementById("productCode").className = "MyText";
	document.getElementById("manufacturingHours").className = "MyText";
	document.getElementById("productType").className = "MySelect";	
	document.getElementById("modelCode").className = "MySelect";
	document.getElementById("familyCodeBy").className = "MyText";
	var objPrompt = document.getElementById("divPrompt");
    objPrompt.style.display = "none";
	objPrompt.innerHTML = "";
}
function ShowFormTitle(strTitle)
{
	document.write("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" style=\"height:26px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_4.gif); background-repeat: repeat-x;\">");
	document.write("  <tr >");
	document.write("	<td style=\"width:5px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_1.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
	document.write("	<td class=\"FormTitle\" style=\"width:100%; padding-left:5px; padding-top:3px; background-position: left bottom; background-image: url(../../resource/image/FormTitle_A_2.gif); background-repeat: no-repeat;\">");
	document.write("		<span id=\"spanFormTitle\" class=\"SpanTitle\">"+ strTitle +"</span>");
	document.write("	</td>");
	document.write("	<td style=\"width:5px; background-position: right bottom; background-image: url(../../resource/image/FormTitle_A_3.gif); background-repeat: no-repeat;\">&nbsp;&nbsp;&nbsp;</td>");
    document.write("  </tr>");
	document.write("</table>");
}
//动态加载modelList  
function FiltModelList()
  {  		
      	var productType = document.getElementById("productType").value;      	      
   		Ext.Ajax.request(
   		{
		url : 'F020201.do' , 
		params : {operationType:'ajax',id:'modelList',productType:productType},
		method: 'POST',
		success: function ( result, request) 
			{
			var listArray = new Array()
			var obj= Ext.decode(result.responseText) ;
			listArray = obj.data.list;
			document.forms[0].modelCode.length = 0;
 	        		for (i=0; i<listArray.length; i++){
           	document.forms[0].modelCode.options[document.forms[0].modelCode.length] = new Option(listArray[i][1], listArray[i][0]);			
    		}
			},	
		failure: function ( result, request) { 
			alert("<bean:message key="adyh.error.request"/>");
			} 
		}
		);
  }
/*----------------------------------bengin---------------------------------*/  
//动态加载 
function comboBox(obj)
  {
  		var strValue = Jtrim(obj.value);   
		if(strValue==""){//检索条件为空时，不检索
			return ;
		}
  
  		if(event.keyCode==38||event.keyCode==40||event.keyCode==13){
			keyEnter();
			return;
		}
  				
		var strId =  obj.name;
		  
		//回显的value1的字段名称
		var strCode = "";
		//回显的value2的字段名称
		var strName = "";		
		
		//相应的div的名称

		var strObj = "rtnList";		
		strTextName=strId		
		//在code处动态输入

		strCode = "familyCode";
		strName = "familyCodeBy";		
		//传入的条件
		var productType=document.getElementById("productType").value;
		var modelCode=document.getElementById("modelCode").value;
		
   		Ext.Ajax.request(
   		{
		url : 'F020201.do' , 
		params : {operationType:'ajax',id:'comboBox',code:strValue,product:productType,model:modelCode},
		method: 'POST',
		success: function ( result, request) 
			{
			var listArray = new Array();
			var obj= Ext.decode(result.responseText) ;
			var objPrompt = document.getElementById(strObj);			
			objPrompt.style.display = "block";		
			objPrompt.innerHTML = "";
			initPosition(strObj);
			listArray = obj.data.list;
			var inn = "<table WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\" bgcolor=\"#FFFFFF\" id=\"sup\" class=\"ListBackground\">";
 	        for (i=0; i<listArray.length; i++){
				inn += "<tr height=\"20\" id=\"row"+(i)+"\"  onClick=\"javascript:show('"+strObj+"','"+listArray[i][0]+"','"+strCode+"','"+listArray[i][1]+"','"+strName+"')\">";
				inn += "<td>";
				inn += listArray[i][1];
				inn += "</td>";
				inn += "</tr>";
			}
			inn+="</table>";
			
			rownum=i;//获取动态加载的行数
			
			//若检索的结果是空，关闭div
			if(listArray.length==1&&listArray[0][0]==""&&listArray[0][1]==""){
				inn = "";
				objPrompt.style.display = "none";
			}
			
			objPrompt.innerHTML += inn;
			if(rownum>0&&inn!=""){
				document.getElementById("row0").focus();
			}
			FocusTableRow1("sup",0);//鼠标划过变色
			setPosition(strObj,strName);	//设置div的位置	
			//KeyCodeTableRow("sup",numsup);//设置当前焦点所在行的颜色

			},	
		failure: function ( result, request) { 
			alert("<bean:message key="adyh.error.request"/>");
			} 
		}
		);
  }

//初始化div的位置

  function initPosition(strObj){
	var objPrompt = document.getElementById(strObj);
	objPrompt.style.top=0;
	objPrompt.style.left=0;
  }
  
  //设置div的位置

  function setPosition(strObjPrompt,strObjText){
  	var objPrompt = document.getElementById(strObjPrompt);
	var objText = document.getElementById(strObjText);
	objPrompt.style.top = 20-(objPrompt.offsetTop-objText.offsetTop);
	objPrompt.style.left = objText.offsetLeft-20;
  }
  
  function initColumn(){  				
  	document.getElementById("familyCode").value = "";
	document.getElementById("familyCodeBy").value = "";
  }
/*----------------------------------end---------------------------------*/    
</script>
</head>

<body>
	<html:form method="post" action="/pages/F02/F020201.do">
		<html:hidden property="operationType" />
		<html:hidden property="familyCode" />
		<html:hidden property="errorFlag" />
		<!--Begin：表单标题-->
		<div class="DivBlock">
			<script language="javascript" type="text/javascript">
		ShowFormTitle("<bean:message key="F020201.title"/>");
	</script>
		</div>
		<!--End：表单标题-->

		<!--Begin：表单主体区块-->
		<div class="DivBlock">
			<div class="DivWrap" style="display:block">
				<TABLE WIDTH="100%" BORDER="0" CELLSPACING="0" CELLPADDING="0">
					<TR>						
						<TD ALIGN="right" NOWRAP WIDTH="15%">
							<!--制造代码--><bean:message key="F02.ProductCode"/>&nbsp;
						</TD>
						<TD ALIGN="left" NOWRAP WIDTH="18%">
							<html:text property="productCode" styleClass="MyText" />
							<span class="Need">*</span>
						</TD>
						<TD ALIGN="right" NOWRAP WIDTH="15%">
							<!--人工工时--><bean:message key="F02.ManufacturingHours"/>&nbsp;
						</TD>
						<TD ALIGN="left" NOWRAP WIDTH="18%">
							<html:text property="manufacturingHours" styleClass="MyText" />
							<span class="Need">*</span>
						</TD>
						<TD ALIGN="right" NOWRAP WIDTH="15%">							
						</TD>
						<TD ALIGN="left" NOWRAP WIDTH="19%">							
						</TD>
					</TR>					
					<TR>
						<TD ALIGN="right" NOWRAP>
							<!--产品类别--><bean:message key="adyh.productType"/>&nbsp;
						</TD>
						<TD ALIGN="left" NOWRAP>
							<html:select property="productType" styleClass="MySelect" onchange="FiltModelList();">							
								<html:optionsCollection property="productList" value="CODE" label="NAME" />
							</html:select>
							<span class="Need">*</span>
						</TD>
						<TD ALIGN="right" NOWRAP>
							<!--模型类别--><bean:message key="F02.ModelType"/>&nbsp;
						</TD>
						<TD ALIGN="left" NOWRAP>
							<html:select property="modelCode" styleClass="MySelect">								
								<html:optionsCollection property="modelList" value="CODE" label="NAME" />
							</html:select>
							<span class="Need">*</span>
						</TD>
						<TD ALIGN="right" NOWRAP>
							<!--家族代码--><bean:message key="F02.FamilyCode"/>&nbsp;
						</TD>
						<TD ALIGN="left" NOWRAP>
							<html:text property="familyCodeBy" styleClass="MyText" onkeyup="comboBox(this)" ondblclick="comboBox(this)" onblur="loseFocus('rtnList')" style="position:relative" />
							<span class="Need">*</span>
						</TD>											
					</TR>									
					<TR>
						<TD ALIGN="right" NOWRAP>
						<!--描述--><bean:message key="adyh.description"/>&nbsp;
						</TD>
						<TD ALIGN="left" NOWRAP colspan="3">
							<html:textarea property="description" styleClass="MyArea" rows="3"
								style="width:96%"></html:textarea>							
						</TD>
						<TD ALIGN="left" NOWRAP>
						</TD>
						<TD ALIGN="right" NOWRAP>
						</TD>
					</TR>					
				</TABLE>
			</div>
		</div>
		<!--End：表单主体区块-->

		<!--Begin：表单按钮及提示区-->
		<div class="DivBlock">
			<div class="DivButton">
				<input type="button" name="Submit1" class="MyButton"
					onClick="ShowAlert()" value="<bean:message key="common.save"/>">
				<input type="button" name="Submit2" class="MyButton" value="<bean:message key="common.back"/>"
					onClick="javascript:operation('back');">
			</div>
			<div class="DivPrompt" id="divPrompt" style="display:none">
			</div>
		</div>
		<!--End：表单按钮及提示区-->
		<div id="rtnList" style="display: black; position:relative; width:135" onmouseleave="col(this);initColumn()">
		</div>
	</html:form>
</body>
</html:html>
<script language="javascript" type="text/javascript">
InitForm();
</script>